from django import forms

from app01.forms.bootstrap import BootStrapForm
from app01 import models
from django.contrib.auth.models import User


class projectDRIform(BootStrapForm, forms.ModelForm):
    class Meta:
        model = models.ProjectDRI
        exclude = ['project']
        widgets = {
            "manufactureruser": forms.Select(attrs={"class": "form-control"}),
            "manufactureruser_leader": forms.Select(attrs={"class": "form-control"}),
            "SMTuser": forms.Select(attrs={"class": "form-control"}),
            "SMTuser_leader": forms.Select(attrs={"class": "form-control"}),
            "AOIuser": forms.Select(attrs={"class": "form-control"}),
            "AOIuser_leader": forms.Select(attrs={"class": "form-control"}),
            "PSAuser": forms.Select(attrs={"class": "form-control"}),
            "PSAuser_leader": forms.Select(attrs={"class": "form-control"}),
            "Glueuser": forms.Select(attrs={"class": "form-control"}),
            "Glueuser_leader": forms.Select(attrs={"class": "form-control"}),
            "automatic": forms.Select(attrs={"class": "form-control"}),
            "automatic_leader": forms.Select(attrs={"class": "form-control"}),
        }
    def __init__(self, request, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['manufactureruser'].queryset = User.objects.all()
        self.fields['manufactureruser_leader'].queryset = User.objects.all()
        self.fields['SMTuser'].queryset = User.objects.all()
        self.fields['SMTuser_leader'].queryset = User.objects.all()
        self.fields['AOIuser'].queryset = User.objects.all()
        self.fields['AOIuser_leader'].queryset = User.objects.all()
        self.fields['PSAuser'].queryset = User.objects.all()
        self.fields['PSAuser_leader'].queryset = User.objects.all()
        self.fields['Glueuser'].queryset =  User.objects.all()
        self.fields['Glueuser_leader'].queryset =  User.objects.all()
        self.fields['automatic'].queryset =  User.objects.all()
        self.fields['automatic_leader'].queryset =  User.objects.all()